package com.example.smartcitydemo.ui.person

import android.view.View
import androidx.fragment.app.Fragment
import androidx.viewpager2.adapter.FragmentStateAdapter
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseDataBindingHolder
import com.example.smartcitydemo.R
import com.example.smartcitydemo.bean.BusOrderInfo
import com.example.smartcitydemo.bean.PersonModifyInfo
import com.example.smartcitydemo.bean.ReplyBean
import com.example.smartcitydemo.databinding.*

/**
 * @PACKAGE_NAME: com.example.smartcitydemo.ui.person
 * @NAME: Caleb.F
 * @DATE: 2021/11/11 8:19
 * @Email: 1919796283@qq.com
 */
val list = listOf(
    "个人信息",
    "订单列表",
    "修改密码",
    "意见反馈"
)

class HomeItemAdapter : BaseQuickAdapter<String, BaseDataBindingHolder<RecyclerPersonItemBinding>>
    (R.layout.recycler_person_item, list.toMutableList()) {
    override fun convert(holder: BaseDataBindingHolder<RecyclerPersonItemBinding>, item: String) {
        holder.dataBinding!!.tvLeft.text = item
    }

}

class PersonModifyAdapter :
    BaseQuickAdapter<PersonModifyInfo, BaseDataBindingHolder<RecyclerPersonItemBinding>>(R.layout.recycler_person_item) {
    override fun convert(
        holder: BaseDataBindingHolder<RecyclerPersonItemBinding>,
        item: PersonModifyInfo
    ) {
        holder.dataBinding?.run {
            tvRight.visibility = View.VISIBLE
            tvLeft.text = item.key
            tvRight.text = item.value
        }
    }
}

class MyBusOderPager2Adapter(val fragment: Fragment, val fragmentList: List<Fragment>) :
    FragmentStateAdapter(fragment) {
    override fun getItemCount(): Int {
        return fragmentList.size
    }

    override fun createFragment(position: Int): Fragment {
        return fragmentList[position]
    }

}

class MyBusOrderDetailAdapter :
    BaseQuickAdapter<BusOrderInfo, BaseDataBindingHolder<RecyclerBusOrderDetailBinding>>(
        R.layout.recycler_bus_order_detail
    ) {
    override fun convert(
        holder: BaseDataBindingHolder<RecyclerBusOrderDetailBinding>,
        item: BusOrderInfo
    ) {
        holder.dataBinding!!.data = item
    }

}


class ReplyMessageAdapter :
    BaseQuickAdapter<ReplyBean, BaseDataBindingHolder<ReyclerCommitReplyItemBinding>>(
        R.layout.reycler_commit_reply_item
    ) {
    override fun convert(
        holder: BaseDataBindingHolder<ReyclerCommitReplyItemBinding>,
        item: ReplyBean
    ) {
        holder.dataBinding!!.data = item
    }
}